Continuation-Passing C, compiling threads to events through continuations
نویسندگان
چکیده
In this paper, we introduce Continuation Passing C (CPC), a programming language for concurrent systems in which native and cooperative threads are unified and presented to the programmer as a single abstraction. The CPC compiler uses a compilation technique, based on the CPS transform, that yields efficient code and an extremely lightweight representation for contexts. We provide a proof of the correctness of our compilation scheme. We show in particular that lambda-lifting, a common compilation technique for functional languages, is also correct in an imperative language like C, under some conditions enforced by the CPC compiler. The current CPC compiler is mature enough to write substantial programs such as Hekate, a highly concurrent BitTorrent seeder. Our benchmark results show that CPC is as efficient, while using significantly less space, as the most efficient thread libraries available.
منابع مشابه
Lambda-lifting and CPS conversion in an imperative language
This paper is a companion technical report to the article “Continuation-Passing C: from threads to events through continuations”. It contains the complete version of the proofs of correctness of lambda-lifting and CPS-conversion presented in the article.
متن کاملCompiling threads to events through continuations
In this paper, we introduce Continuation Passing C (CPC), a programming language for concurrent systems in which native and cooperative threads are unified and presented to the programmer as a single abstraction. The CPC compiler uses a compilation technique, based on the CPS transform, that yields efficient code and an extremely lightweight representation for contexts. We provide a proof of th...
متن کاملCPC Compiling threads to events efficiently
We present Continuation Passing C (CPC), a programming language designed for writing concurrent systems. It features very lightweight threads, both cooperatively or preemptively scheduled, which are compiled to highly-efficient event-loop code. Its compilation passes have been proven correct. CPC has been used to write Hekate, a BitTorrent seeder able to sustain thousands of simultaneously conn...
متن کاملContinuation Passing for C A space-efficient implementation of concurrency
Threads are a convenient abstraction for programming concurrent systems. They are however expensive, which leads many programmers to use coarse-grained concurrency where a fine-grained structure would be preferable, or use more cumbersome implementation techniques. Cooperative threads can be easily implemented in a language that provides first-class continuations. Unfortunately, CPS conversion,...
متن کاملNo Assembly Required : Compiling Standard ML
C has been used as a portable target language for implementing languages like Standard ML and Scheme. Previous eeorts at compiling these languages to C have produced eecient code, but also compromised on portability and proper tail-recursion. We show how to compile Standard ML to C without making such compromises. The compilation technique is based on converting Standard ML to a continuation-pa...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید
ثبت ناماگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید
ورودعنوان ژورنال:
- Higher-Order and Symbolic Computation
دوره 24 شماره
صفحات -
تاریخ انتشار 2011